<template>
  <view class="message">
    <template>
      <view class="topBar justify_center">
        <view class="title">消息中心</view>
        <image
          @click="clearUnread"
          class="clear_icon"
          src="/static/img/message/clear_icon.png"
          mode="scaleToFill"
        />
      </view>
      <view class="main">
        <view class="scroll-main">
          <view class="top">
            <view
              class="kong_item flex_column"
              v-for="(item, index) in tabsList"
              :key="index"
              @click="onClickItem(item, 1)"
            >
              <image class="kong_img" :src="item.icon" mode="scaleToFill" />
              <text class="kong_name">{{ item.name }}</text>
              <view
                v-if="item.msgNum != 0 && index != 2"
                :class="['kong_num' + index, 'kong_num']"
              >
                {{ item.msgNum }}
              </view>
              <view
                v-if="index == 2 && GGLengthStorage != GGLength"
                class="redDot"
              ></view>
            </view>
          </view>
          <view style="height: 8rpx; background-color: #f3f3f3"></view>
          <view class="con">
            <view
              class="informItem justify_center"
              @click="onClickItem(item, 2)"
              v-for="(item, index) in informList"
              :key="index"
            >
              <image class="informIcon" :src="item.icon" mode="scaleToFill" />
              <view class="informContent">
                <view class="informTitle flex_between">
                  <view class="informName">{{ item.name }}</view>
                  <view class="informTime">{{ item.time }}</view>
                </view>
                <view class="informText flex_between">
                  <view class="informTxt">{{ item.msgTxt }}</view>
                  <view
                    class="informNum"
                    v-if="item.msgNum != 0 && index != 1 && item.msgNum != ''"
                    >{{ item.msgNum }}</view
                  >
                  <view
                    v-if="index == 1 && ALengthStorage != ALength"
                    class="redDot"
                  ></view>
                </view>
              </view>
            </view>

            <!-- 问答 -->
            <view
              class="informItem justify_center"
              @click="onClickItem(askInfo, 3)"
              v-if="proceedFlag"
            >
              <image
                class="informIcon"
                :src="askInfo.icon"
                mode="scaleToFill"
              />
              <view class="informContent">
                <view class="informTitle flex_between">
                  <view class="informName">{{ askInfo.name }}</view>
                  <view class="informTime">{{ askInfo.time }}</view>
                </view>
                <view class="informText flex_between">
                  <view class="informTxt">{{ askInfo.msgTxt }}</view>
                  <view class="informNum" v-if="askInfo.msgNum != 0">{{
                    askInfo.msgNum
                  }}</view>
                </view>
              </view>
            </view>

            <!-- 企服 -->
            <view
              class="informItem justify_center"
              @click="onClickItem(serverInfo, 4)"
            >
              <image
                class="informIcon"
                :src="serverInfo.icon"
                mode="scaleToFill"
              />
              <view class="informContent">
                <view class="informTitle flex_between">
                  <view class="informName">{{ serverInfo.name }}</view>
                  <view
                    class="informTime"
                    v-if="$store.state.conversationList.length > 0"
                    >{{
                      $moment(
                        $store.state.conversationList[0].lastMessage.timestamp
                      ).format("MM-DD")
                    }}</view
                  >
                </view>
                <view class="informText flex_between">
                  <view class="informTxt">{{
                    $store.state.serverNum == 0
                      ? "请点击查看"
                      : "您当前有需求正在沟通中，请点击查看"
                  }}</view>
                  <view
                    class="informNum"
                    v-if="
                      $store.state.serverNum != 0 &&
                      userInfo.is_major != 1 &&
                      isLogin
                    "
                    >{{ $store.state.serverNum }}</view
                  >
                </view>
              </view>
            </view>
          </view>
        </view>
      </view>
    </template>

    <!-- 打开通知设置弹窗 -->
    <!-- <view v-if="systemPopupShow">
      <systemPopup :systemPopupShow.sync="systemPopupShow"></systemPopup>
    </view> -->
  </view>
</template>

<script
  type="text/javascript"
  src="plus-confusion://../pages/message/index/index"
></script>

<style scoped lang="scss">
.message {
  background: #fff !important;
  min-height: 100vh;
}

.main {
  background: #fff !important;
  border-top: 1rpx solid #e5e5e5;
}

.scroll-main {
  height: 100%;
  .top {
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 66rpx 0;

    .item {
      position: relative;
      margin: 0 60rpx;
      text-align: center;

      image {
        width: 85rpx;
        height: 76rpx;
      }

      .text {
        padding-top: 12rpx;
        font-size: 28rpx;
        font-family: Source Han Sans CN-Regular, Source Han Sans CN;
        color: #333333;
        line-height: 40rpx;
      }
    }

    .kong_item {
      align-items: center;
      position: relative;

      .kong_img {
        width: 102rpx;
        height: 102rpx;
        margin-bottom: 20rpx;
      }

      .kong_name {
        font-size: 30rpx;
        font-family: OPPOSans, OPPOSans;
        font-weight: 600;
        color: #333333;
        line-height: 40rpx;
      }

      .kong_num {
        width: 35rpx;
        height: 35rpx;
        background: #fa5151;
        border-radius: 50%;
        color: #fff;
        position: absolute;
        top: 0;
        right: -10rpx;
        font-size: 24rpx;
        line-height: 35rpx;
        text-align: center;
      }
    }
  }

  .con {
    background-color: #fff;
    margin-top: 10rpx;

    .item {
      display: flex;
      justify-content: center;
      width: 750rpx;
      box-sizing: border-box;
      padding-top: 37rpx;
      .left {
        margin-right: 25rpx;
      }

      .center {
        font-family: Source Han Sans CN-Regular, Source Han Sans CN;
        display: flex;
        align-items: center;
        border-bottom: 1rpx solid #eaeaea;
        padding-bottom: 31rpx;

        .text-info {
          width: 500rpx;
          padding-right: 25rpx;
          box-sizing: border-box;
        }

        .text1 {
          font-size: 26rpx;
          color: #666666;
          line-height: 40rpx;
        }

        .text2 {
          font-size: 32rpx;
          color: #333333;
          line-height: 40rpx;
          padding: 12rpx 0;
        }

        .text3 {
          font-size: 24rpx;
          font-family: MiSans-Normal, MiSans;
          color: #b8b8b8;
          line-height: 40rpx;
        }
      }

      .right {
        image {
          width: 40rpx;
        }
      }
    }

    .informItem {
      padding: 40rpx;
      width: 100%;
      box-sizing: border-box;

      &:not(:last-child) {
        border-bottom: 2rpx solid #eeeeee;
      }

      .informIcon {
        width: 95rpx;
        height: 95rpx;
      }

      .informContent {
        margin-left: 30rpx;
        width: calc(100% - 135rpx);

        .informTitle {
          font-size: 32rpx;
          font-weight: 600;
          color: #333333;
          line-height: 40rpx;

          .informTime {
            font-size: 24rpx;
            color: #999999;
            line-height: 40rpx;
          }
        }

        .informText {
          margin-top: 10rpx;
          position: relative;

          .informTxt {
            width: 500rpx;
            font-size: 24rpx;
            color: #999999;
            line-height: 40rpx;
            display: -webkit-box;
            -webkit-line-clamp: 1;
            -webkit-box-orient: vertical;
            overflow: hidden;
          }

          .informNum {
            width: 35rpx;
            height: 35rpx;
            background: #fa5151;
            color: #fff;
            border-radius: 50%;
            text-align: center;
            line-height: 35rpx;
          }
        }
      }
    }
  }
}

.topBar {
  padding: 23rpx 34rpx;
  position: relative;
  padding-top: calc(var(--status-bar-height) + 23rpx);

  .title {
    font-size: 40rpx;
    font-weight: bold;
    font-family: Source Han Sans, Source Han Sans;
    color: rgba(0, 0, 0, 0.8);
    line-height: 40rpx;
  }

  .clear_icon {
    width: 40rpx;
    height: 40rpx;
    position: absolute;
    top: calc(var(--status-bar-height) + 23rpx);
    right: 34rpx;
  }
}

.redDot {
  width: 20rpx;
  height: 20rpx;
  background: #fa5151;
  border-radius: 50%;
  position: absolute;
  top: 0;
  right: 0;
}
</style>
